import 'package:flutter/material.dart';
import '../services/user.dart';
class Userinfo with ChangeNotifier {
  Map<String,dynamic> _userInfo={};
  Map<String,dynamic> get userInfo => _userInfo;
  //获取登录状态
  Future<bool> get isLogin async{
    return await hasLogin();
  }
  //获取用户信息
  getUserInfo() async{
    if(await isLogin){
      this._userInfo =await User.getUserInfo();
      print(this._userInfo);
    }else{
      this._userInfo.clear();
    }
    notifyListeners();
  }
  //清除用户信息
  clearUserInfo(){
    this._userInfo.clear();
    User.loginOut();
    notifyListeners();
  }
  //判断是否是登录状态
  Future<bool> hasLogin() async{
    return await User.hasLogin();
  }


}
